home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / util / setcpu16 / part03 < prev    next >
Encoding:
Text File  |  1990-08-14  |  47.6 KB  |  1,277 lines

  1. Newsgroups: comp.sources.amiga
  2. Path: abcfd20.larc.nasa.gov!amiga-request
  3. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  4. Subject: v90i223: SetCPU 1.60 - identify and adjust parameters based on cpu type, Part03/04
  5. Message-ID: <comp.sources.amiga:v90i223@abcfd20.larc.nasa.gov>
  6. Sender: tadguy@abcfd20.larc.nasa.gov (Tad Guy)
  7. Reply-To: daveh@cbmvax.commodore.com (Dave Haynie)
  8. X-Post-Discussions-To: comp.sys.amiga
  9. Organization: NASA Langley Research Center, Hampton, VA  USA
  10. Date: 14 Aug 90 21:39:56 GMT
  11. Approved: tadguy@abcfd01.larc.nasa.gov (Tad Guy)
  12. X-Mail-Submissions-To: amiga@uunet.uu.net
  13.  
  14. Submitted-by: daveh@cbmvax.commodore.com (Dave Haynie)
  15. Posting-number: Volume 90, Issue 223
  16. Archive-name: util/setcpu-1.60/part03
  17.  
  18. #!/bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 3 (of 4)."
  25. # Contents:  SetCPU.c SetCPU.txt
  26. # Wrapped by tadguy@abcfd20 on Tue Aug 14 17:35:36 1990
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'SetCPU.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'SetCPU.c'\"
  30. else
  31. echo shar: Extracting \"'SetCPU.c'\" \(23981 characters\)
  32. sed "s/^X//" >'SetCPU.c' <<'END_OF_FILE'
  33. X/*
  34. X    SetCPU V1.60
  35. X    by Dave Haynie, April 13, 1990
  36. X    Released to the Public Domain
  37. X
  38. X    MAIN PROGRAM
  39. X
  40. X    This program is a CPU identification and MMU support tool for the
  41. X    Amiga operating system.  It will identify various CPU system 
  42. X    elements, and allow decisions to be made based on those elements
  43. X    in script files.  It will also use the MMU on systems so equipped
  44. X    to translate system ROM, or alternate system ROMs, into system
  45. X    memory, with preference given to any 32 bit memory it might be
  46. X    able to detect.
  47. X
  48. X    While this program does attempt to support the 68040, it hasn't
  49. X    been tested on a 68040 yet.  It doesn't attempt to support any
  50. X    of the MMU setups on a 68040 system just yet.
  51. X*/
  52. X
  53. X#define MAIN_MODULE
  54. X
  55. X#include "setcpu.h"
  56. X
  57. X/* ====================================================================== */
  58. X
  59. X/* Global options */
  60. X
  61. XBOOL    tags[CHECKS],            /* Check system tags */
  62. X    verbose     = FALSE,    /* Display lots of info? */
  63. X    helpmode    = FALSE,    /* Do we just want help? */
  64. X    handler        = TRUE,        /* Install trap handler? */
  65. X    allochead    = FALSE,    /* Allocate from head of memory */
  66. X    keepexec    = FALSE,    /* Preserve ExecBase on KICKROM? */
  67. X    stack        = TRUE,        /* Try a stack translation? */
  68. X    aliens        = FALSE;    /* MMU setup from space? */
  69. X        
  70. Xshort    fastrom     = 0,        /* Set up the FASTROM? */
  71. X    wrapbits    = 8,        /* How does the MMU wrap addresses? */
  72. X    forcewrap    = -1,        /* Forced addressing size */
  73. X    quitcode    = 0;        /* Termination code */
  74. X
  75. Xchar    *romfile    = NULL;        /* Where to look for a kick image */
  76. X
  77. XULONG     bootdelay    = 0x00400000,    /* Basic reboot-loop delay */
  78. X    cpu,                /* CPU type */
  79. X    fpu,                /* FPU type */
  80. X    mmu,                /* MMU type */
  81. X    oldCACR,            /* CACR when we start. */
  82. X    newCACR;            /* New CACR value. */
  83. X
  84. X/* Do we want autoconfig?  I think a default level 2 makes more sense. */
  85. X
  86. Xshort    configlevel     = 2;        
  87. XBOOL    configset    = FALSE;
  88. X
  89. X/* ====================================================================== */
  90. X
  91. X/* This is the termination routine, which also displays numbered errors. */
  92. X
  93. Xvoid quit(err)
  94. Xint err;
  95. X{
  96. X   if (err >= 10) printf("Error: ");
  97. X   switch(err) { 
  98. X      case 1:
  99. X         printf("Usage: SetCPU [INST|DATA] [[NO]CACHE|[NO]BURST] [CONFIG n] [BITS n] [TRAP n]\n");
  100. X         printf("              [KICKROM path|dfN: [DELAY n] [KEEPEXEC]] [CARDROM path] [VERBOSE]\n");
  101. X         printf("              [[NO]FASTROM [path] [KEYPATCH n] [HEAD] [NOSTACK]] [ROMBOOT]\n");
  102. X         printf("              [CHECK 680x0|68851|6888x|MMU|FPU|MMUON|MMUROM|MMUALIEN]\n");
  103. X         break;   
  104. X      case 11: printf("Invalid numeric parameter value\n");    break;
  105. X      case 12: printf("Illegal Command Line Option\n");        break;
  106. X      case 13: printf("KICKROM translation can't be removed\n");break;
  107. X      case 14: printf("Can't get memory for FASTROM\n");    break;
  108. X      case 15: printf("Can't locate specified file\n");        break;
  109. X      case 16: printf("Invalid device specified\n");        break;
  110. X      case 17: printf("KEYPATCH requires FASTROM\n");        break;
  111. X      case 18: printf("Can't get memory for KICKROM\n");    break;
  112. X      case 19: printf("Option requires a file name argument\n");break;
  113. X      case 20: printf("System is already FASTKICKed\n");    break;
  114. X      case 21: printf("File/ROM version mismatch, use KICKROM\n"); break;
  115. X      case 22: printf("KICKROM file format invalid\n");        break;
  116. X      case 23: printf("KICKROM file too short\n");        break;
  117. X      case 24: printf("KICKROM file not found\n");        break;
  118. X      case 25: printf("ROMBOOT can't be used with other options\n"); break;
  119. X      case 26: printf("68040 MMU setups not supported\n");    break;
  120. X      case 27: printf("Alien MMU setup prevents FASTROM\n");    break;
  121. X      default:  break;
  122. X   }
  123. X
  124. X   if (ExpansionBase) CloseLibrary(ExpansionBase);
  125. X
  126. X   if (cpu >= 68020L) SetCACR(((err>10)?oldCACR:newCACR) | CACR_FIXED);
  127. X   exit((err>10)?10:err);
  128. X}
  129. X
  130. X/* ====================================================================== */
  131. X
  132. X/* A bit of magic for the smart reset code. */
  133. X
  134. X#define COLDREBOOTVECT -726L
  135. X
  136. X/* This routine installs the given valid rom image as a fast ROM.  It will
  137. X   install any I/O translations that are appropriate, and also apply the
  138. X   system patch list to the ROM image, before engaging the MMU. */
  139. X
  140. Xstatic BOOL CreateFastROM(tag,wrapbits)
  141. Xstruct systag *tag;
  142. Xshort wrapbits;
  143. X{
  144. X   ULONG *VBR = GetVBR();
  145. X   struct ExecBase *eb = *((struct ExecBase **)4L);
  146. X
  147. X   if (!tag) return FALSE;
  148. X
  149. X   tag->wrapup = (wrapbits < tag->wrapdown) ? wrapbits : tag->wrapdown;
  150. X
  151. X  /* Here I'll add in subtables for any I/O devices that we've been told
  152. X     about, that I can locate. */
  153. X
  154. X   MakeExpTable(tag);
  155. X
  156. X  /* Here I apply the patches to this ROM. */
  157. X
  158. X   AddPatch((UWORD *)tag->romhi,SystemPatch,tag);
  159. X   tag->patchlist = lastpatch;   
  160. X
  161. X  /* How 'bout that exception handler.  I get the Vector Base Register,
  162. X     save the old vector, allocate space for the new one if needed, copy it
  163. X     from my SetCPU code, and assign it.  The tag keeps track of all of this
  164. X     so that I can easily remove the whole thing if FASTROM is turned off. */
  165. X  
  166. X   if (handler) {
  167. X      tag->OldBerr = (char *)VBR[2];
  168. X      tag->BerrSize = BerrCodeSize;
  169. X      tag->BerrHandler = (char *)AllocMem(tag->BerrSize,MEMF_PUBLIC);
  170. X      MemCopy(BerrCode,tag->BerrHandler,tag->BerrSize);
  171. X      VBR[2] = (ULONG)tag->BerrHandler;
  172. X   }
  173. X
  174. X  /* Should we have a smart reset bit? */
  175. X
  176. X   if (eb->LibNode.lib_Version >= 36) {
  177. X      tag->ResetCode = (char *)AllocMem(tag->ResetSize = ResetCodeSize,0L);
  178. X      MemCopy((char *)ResetCode,tag->ResetCode,tag->ResetSize);
  179. X      tag->OldReset = SetFunction(eb,COLDREBOOTVECT,tag->ResetCode);
  180. X   } 
  181. X
  182. X  /* Bang the MMU my way */
  183. X
  184. X   SetMMURegs(tag);
  185. X   Disable();
  186. X   SetMMUTag(tag);
  187. X
  188. X  /* How about that system stack. This is done here, since the MMU is already
  189. X     on, and I need to do supervisor-mode stuff to turn it on, but no to set
  190. X     up the fast stack. */
  191. X
  192. X   if (stack) MakeFastStack(tag);
  193. X
  194. X   Enable();
  195. X   return TRUE;
  196. X}
  197. X
  198. X/* This routine creates a kickable ROM, based on the image in the systag.
  199. X   If the Kick ROM can't be allocated, the routine returns FALSE, otherwise,
  200. X   TRUE. */
  201. X
  202. Xstatic BOOL CreateKickROM(temptag,wrapbits) 
  203. Xstruct systag *temptag;
  204. Xshort wrapbits;
  205. X{
  206. X   struct systag *tag;
  207. X   ULONG *VBR = GetVBR();
  208. X
  209. X   if (!temptag || LoadErr) return FALSE;
  210. X
  211. X  /* We disable so that nothing else is running; the RAMBoot() routine
  212. X     counts on the instruction cache, so we might as well turn that on
  213. X     now as well. */
  214. X
  215. X   Forbid();
  216. X   Disable();
  217. X  /* Now I need a new tag, based on safe memory.  Note that calling the safe
  218. X     allocator will very likely crash the system if we're not disabled. */
  219. X
  220. X   if (!(tag = AllocSAFEImage(temptag))) {
  221. X      Enable(); 
  222. X      return FALSE;
  223. X   }
  224. X
  225. X   tag->wrapup = (wrapbits < tag->wrapdown) ? wrapbits : tag->wrapdown;
  226. X   
  227. X   if (configlevel == 1 || configlevel == 0) {
  228. X      tag->maintable[0xe80000L/ROMROUND] = PD_ADDR(0x800000)|PD_DT_PAGE;
  229. X      tag->config = FALSE;
  230. X   }
  231. X
  232. X  /* How 'bout that exception handler.  I get the Vector Base Register,
  233. X     save the old vector, allocate space for the new one if needed, copy it
  234. X     from my SetCPU code, and assign it.  The tag keeps track of all of this
  235. X     so that I can easily remove the whole thing if FASTROM is turned off. */
  236. X
  237. X   if (handler) {
  238. X      tag->BerrSize = BerrCodeSize;
  239. X      MemCopy(BerrCode,tag->BerrHandler,tag->BerrSize);
  240. X      VBR[2] = (ULONG)tag->BerrHandler;
  241. X   }
  242. X   SetMMURegs(tag);
  243. X   RAMBoot(tag,(LONG)keepexec,bootdelay);
  244. X   return FALSE;
  245. X}
  246. X
  247. X/* This routine removes the Fast ROM, and re-claims the memory previously
  248. X   allocated.  We've already checked to make sure that the MMU was 
  249. X   switched on. */
  250. X
  251. Xstatic void DeleteFastROM(tag)
  252. Xstruct systag *tag;
  253. X{
  254. X   ULONG *VBR;
  255. X   struct MemChunk *mem, *del;
  256. X   struct ExecBase *eb = *((struct ExecBase **)4L);
  257. X
  258. X  /* First off, turn off the MMU and caches.  This lets us muck with the table 
  259. X     and reclaim memory without any trouble. */
  260. X
  261. X   if (tag->romtype != ROM_FAST) quit(13);
  262. X   if (tag->sysstack) FreeFastStack(tag);
  263. X   SetTC(0L);
  264. X
  265. X  /* First I free any subtable stuff that was allocated. */
  266. X   FreeExpROM(tag->devs);
  267. X
  268. X  /* Now I delete the patches for any patch lists I've got.  They only get
  269. X     deleted if they've been applied. */
  270. X   mem = tag->patchlist;
  271. X   while (mem) {
  272. X      del = mem;
  273. X      mem = mem->mc_Next;
  274. X      FreeMem(del,del->mc_Bytes);
  275. X   }
  276. X
  277. X  /* Remove the bus error handler, if there is one. */
  278. X   if (tag->BerrHandler) {
  279. X      VBR = GetVBR();
  280. X      VBR[2] = (ULONG)tag->OldBerr;
  281. X      if (tag->OldBerr) FreeMem(tag->BerrHandler,tag->BerrSize);
  282. X   }
  283. X
  284. X  /* Did we have a smart reset bit? */
  285. X
  286. X   if (tag->ResetCode && tag->OldReset) {
  287. X      SetFunction(eb,COLDREBOOTVECT,tag->OldReset);
  288. X      FreeMem(tag->ResetCode,tag->ResetSize);
  289. X   }
  290. X
  291. X  /* Now I just free up table and ROM image memory, and I'm done!  I can free
  292. X     the table I built for any subtable here, and then the main table and
  293. X     image. */
  294. X  
  295. X   FreeMMUTable(tag);
  296. X
  297. X   if (tag->tagsize <= 66L || !tag->romlo)
  298. X      FreeMem(tag->romhi,SMALLROMSIZE);
  299. X   else if (tag->romlo)
  300. X      FreeMem(tag->romlo,tag->romsize);
  301. X   FreeMem(tag,tag->tagsize);
  302. X}
  303. X
  304. X/* This routine displays the ROM image information. */
  305. X
  306. Xstatic void PrintFastROM() {
  307. X   struct systag *tag;
  308. X   struct ExpROMData *dev;
  309. X   struct ExecBase *eb = *((struct ExecBase **)4L);
  310. X
  311. X   if (!(tag = GetSysTag())) return;
  312. X
  313. X   printf("TABLE : (PADDR: $%8lx) (SIZE: %ld) (WRAP: %d)\n",
  314. X      tag->maintable,tag->tablesize/4,tag->wrapup);
  315. X
  316. X   if (tag->romlo)
  317. X      printf("KERNEL: (PADLO: $%8lx) (PADHI: $%8lx) (VADDR: $%8lx) (SIZE: %ldK)\n",
  318. X         tag->romlo,tag->romhi,tag->romloc,tag->romsize/1024);
  319. X   else
  320. X      printf("KERNEL: (PADDR: $%8lx) (VADDR: $%8lx) (SIZE: %ldK)\n",
  321. X         tag->romhi,tag->romloc,tag->romsize/1024);
  322. X   if (tag->sysstack)
  323. X      printf("SSTACK: (PADDR: $%8lx) (VADDR: $%8lx) (SIZE: %ldK)\n",
  324. X         tag->sysstack,eb->SysStkLower,((ULONG)eb->SysStkUpper - (ULONG)eb->SysStkLower + 1)/1024);
  325. X   if (tag->ResetCode)
  326. X      printf("REBOOT: (NVECT: $%8lx) (OVECT: $%8lx) (SIZE: $%lx)\n",
  327. X         tag->ResetCode,tag->OldReset,tag->ResetSize);
  328. X
  329. X  /* Now we'll explain any device stuff that's here. */
  330. X   for (dev = tag->devs; dev; dev = dev->next) {
  331. X      printf("DEVICE: %sE\n",dev->name);
  332. X      printf("        (PADDR: $%8lx) (TABLE: $%8lx) (SIZE: %ldK)\n",
  333. X             dev->imagebase, dev->tablebase, dev->ROMsize/1024);
  334. X   }
  335. X}
  336. X
  337. X/* Basic "Do I do configuration" logic */
  338. X
  339. Xvoid SetupConfig(tag)
  340. Xstruct systag *tag;
  341. X{
  342. X   if (configlevel > 0) {
  343. X      tag->maintable[0xe80000L/ROMROUND] = PD_ADDR(0xe80000L)|PD_DT_PAGE;
  344. X      if (configlevel > 1) SafeConfigDevs();
  345. X   }
  346. X}
  347. X
  348. X/* ====================================================================== */
  349. X
  350. X/* This function scopes out the two key expansion devices, Bridge Card or
  351. X   known-to-be-32-bit memory. */
  352. X
  353. Xvoid SnoopDevs() {
  354. X   struct ConfigDev *cd;
  355. X
  356. X   if ((cd = FindConfigDev(NULL,0x201L,0x01L)) || (cd = FindConfigDev(NULL,0x201L,0x02L))) {
  357. X      Bridge.Addr = (ULONG)cd->cd_BoardAddr;
  358. X      Bridge.Size = (ULONG)cd->cd_BoardSize;
  359. X   }
  360. X
  361. X   if ((cd = FindConfigDev(NULL,0x202L,0x50L)) || (cd = FindConfigDev(NULL,0x202L,0x51L))) {
  362. X      A26x0.Addr = (ULONG)cd->cd_BoardAddr;
  363. X      A26x0.Size = (ULONG)cd->cd_BoardSize;
  364. X   }     
  365. X}
  366. X
  367. X/* ====================================================================== */
  368. X
  369. X/* Codes for the FASTROM action. */
  370. X
  371. X#define    FR_NO_ACTION    0
  372. X#define    FR_DELETE    1
  373. X#define    FR_MKFAST    ROM_FAST
  374. X#define FR_MKKICK    ROM_KICK
  375. X
  376. X/* Command line tokens */
  377. X
  378. Xstatic char *CLITokens[] = 
  379. X   { "68000","68010","68020","68030","68040","68851","68881","68882","FPU",
  380. X     "MMU","MMUON","MMUROM","MMUALIEN","CHECK", "FASTROM", "NOFASTROM",
  381. X     "NOPATCH","KEYPATCH","TRAP", "DATA", "INST", "CACHE", "NOCACHE", "BURST",
  382. X     "NOBURST","VERBOSE", "KICKROM", "CARDROM", "CONFIG", "HEAD", "DELAY",
  383. X     "KEEPEXEC","ROMBOOT","NOSTACK","BITS","?" };
  384. X   
  385. X#define CT_CHECK    CHECKS+0
  386. X#define CT_FASTROM    CHECKS+1
  387. X#define CT_NOFROM    CHECKS+2
  388. X#define CT_NOPATCH    CHECKS+3
  389. X#define CT_KEYPAT    CHECKS+4
  390. X#define CT_TRAP        CHECKS+5
  391. X#define CT_DATA        CHECKS+6
  392. X#define CT_INST        CHECKS+7
  393. X#define CT_CACHE    CHECKS+8
  394. X#define CT_NOCACHE    CHECKS+9
  395. X#define CT_BURST    CHECKS+10
  396. X#define CT_NOBURST    CHECKS+11
  397. X#define CT_VERBOSE    CHECKS+12
  398. X#define CT_KICKROM    CHECKS+13
  399. X#define CT_CARDROM    CHECKS+14
  400. X#define CT_CONFIG    CHECKS+15
  401. X#define CT_HEAD        CHECKS+16
  402. X#define CT_DELAY    CHECKS+17
  403. X#define CT_KEEPEX    CHECKS+18
  404. X#define CT_ROMBOOT    CHECKS+19
  405. X#define CT_NOSTACK    CHECKS+20
  406. X#define CT_BITS        CHECKS+21
  407. X#define CT_HELP        CHECKS+22
  408. X
  409. X/* This function fetches a bounded numeric value, or takes the error trap
  410. X   for numeric arguments if things aren't right. */
  411. X   
  412. Xshort getnumber(arg,low,high)
  413. Xchar *arg;
  414. Xshort low, high;
  415. X{
  416. X   short num;
  417. X
  418. X   if (!arg || !isdigit(*arg) || (num = atoi(arg)) < low || num > high) 
  419. X      quit(11);
  420. X   return num;
  421. X}
  422. X
  423. X/* This is basically the DiskSalv command-line parser re-written for the
  424. X   SetCPU command set. */
  425. X
  426. Xstatic USHORT ParseCommandLine(argc,argv)
  427. Xint argc;
  428. Xchar **argv;
  429. X{
  430. X   short i,j, trapmode = 0, bitcnt;
  431. X   struct patch *p;
  432. X   BPTR lock;
  433. X   ULONG mode = CACR_INST | CACR_DATA;
  434. X   char *file;
  435. X   BOOL f_FASTROM = FALSE, f_KEYPAT = FALSE;
  436. X   
  437. X   for (i = 1; i < argc; i++) {
  438. X      for (j = 0; CLITokens[j] && !striequ(argv[i],CLITokens[j]); ++j);
  439. X      if (j < CHECKS) {
  440. X         if (quitcode != WARNING) return 12;
  441. X         tags[j] = TRUE;
  442. X      } else switch (j) {
  443. X         case CT_CHECK    : quitcode = WARNING;            break;
  444. X         case CT_NOFROM    : fastrom = FR_DELETE;            break;
  445. X         case CT_DATA    : mode = CACR_DATA;            break;
  446. X         case CT_INST   : mode = CACR_INST;            break;
  447. X         case CT_CACHE    : newCACR |=   mode << CACR_ENABLE;    break;
  448. X         case CT_NOCACHE: newCACR &= ~(mode << CACR_ENABLE);    break;
  449. X         case CT_BURST    : newCACR |=   mode << CACR_BURST;    break;
  450. X         case CT_NOBURST: newCACR &= ~(mode << CACR_BURST);    break;
  451. X         case CT_VERBOSE: verbose = TRUE;            break;
  452. X         case CT_HEAD    : allochead = TRUE;            break;
  453. X         case CT_KEEPEX    : keepexec = FALSE;            break;
  454. X         case CT_HELP    : helpmode = TRUE;            break;
  455. X         case CT_NOSTACK: stack = FALSE;            break;
  456. X         case CT_ROMBOOT: 
  457. X            if (argc != 2) 
  458. X               quit(25);
  459. X            else 
  460. X               CleanBoot();
  461. X         case CT_TRAP    : 
  462. X            if (argv[i+1] && isdigit(argv[i+1][0]))
  463. X               trapmode = getnumber(argv[++i],0,2);
  464. X            if (trapmode == 0) wrapbits = 0;
  465. X            handler = (trapmode == 2);
  466. X            break;
  467. X         case CT_BITS    :
  468. X            if (argv[i+1] && isdigit(argv[i+1][0]))
  469. X               bitcnt  = getnumber(argv[++i],24,32);
  470. X            forcewrap = 32-bitcnt;
  471. X            break;
  472. X         case CT_CONFIG    : 
  473. X            configset = TRUE;
  474. X            configlevel = getnumber(argv[++i],0,2);
  475. X            break;
  476. X         case CT_DELAY:
  477. X            bootdelay = 0x60000L*(ULONG)getnumber(argv[++i],0,100);
  478. X            break;
  479. X         case CT_KEYPAT    :
  480. X             SetKeyDelay(100L * (ULONG)getnumber(argv[++i],1,100));
  481. X             for (p = SystemPatch; p; p = p->next)
  482. X                if (p->list[KEYPATCH].Type == PT_KEYBOARD) {
  483. X                   p->list[KEYPATCH].Length = KeyCodeSize;
  484. X                   p->list[KEYPATCH].Code = (UWORD *)KeyCode;
  485. X                   p->list[KEYPATCH].Type = PT_JSR;
  486. X                }
  487. X            f_KEYPAT = TRUE;
  488. X            break;
  489. X         case CT_NOPATCH: 
  490. X            for (p = SystemPatch; p; p = p->next) {
  491. X               j = 0;
  492. X               while (p->list[j].Type != PT_END) {
  493. X                  if (j != KEYPATCH && p->list[j].Type < PT_END)
  494. X                     p->list[j++].Type = PT_IGNORE;
  495. X                  else
  496. X                     ++j;                        
  497. X               }
  498. X            }
  499. X            break;
  500. X         case CT_FASTROM: 
  501. X            fastrom = FR_MKFAST;
  502. X            if (i+1 < argc && (lock = Lock(argv[i+1],ACCESS_READ))) {
  503. X               UnLock(lock);
  504. X               romfile = argv[++i];
  505. X            }
  506. X            f_FASTROM = TRUE;
  507. X            break;
  508. X         case CT_KICKROM:
  509. X            fastrom = FR_MKKICK;
  510. X            if (!(romfile = argv[++i])) return 19;
  511. X            break;
  512. X         case CT_CARDROM:
  513. X            if (!(file = argv[++i])) return 19;
  514. X            if (!ReadExpDevs(file)) return 15;
  515. X            break;
  516. X
  517. X         default: return 12;
  518. X      }
  519. X   }
  520. X   if (f_KEYPAT && !f_FASTROM) return 17;
  521. X
  522. X   return 0;
  523. X}
  524. X
  525. X
  526. X/* ====================================================================== */
  527. X
  528. X/* This routine prints FPU codes and sets things accordingly. */
  529. X
  530. Xvoid PrintFPU()
  531. X{
  532. X   if (fpu == 68881L) {
  533. X      printf("68881 ");
  534. X      if (tags[CK68881]) quitcode = 0;
  535. X   } else if (fpu == 68882L) {
  536. X      printf("68882 ");
  537. X      if (tags[CK68882]) quitcode = 0;
  538. X   }
  539. X   if (fpu && tags[CKFPU]) quitcode = 0;
  540. X}
  541. X
  542. X/* This program displays the system CPU setup and sets any appropriate check
  543. X   flags. */
  544. X
  545. Xvoid PrintSystem() {
  546. X   ULONG mmuon,dmask = CACR_DATA,imask = CACR_INST,shft = CACR_ENABLE;
  547. X   struct systag *tag;
  548. X
  549. X   printf("SYSTEM: ");
  550. X
  551. X   /* If they're not on a 68020/68030, we can't set anything.  For 
  552. X      compatibility across systems, I don't consider a cache setting 
  553. X      request an error, just ignore it. */
  554. X
  555. X   if (cpu <= 68010L) {
  556. X      if (cpu == 68010L) {
  557. X         printf("68010 ");
  558. X         if (tags[CK68010]) quitcode = 0;
  559. X      } else {
  560. X         printf("68000 ");
  561. X         if (tags[CK68000]) quitcode = 0;
  562. X      }
  563. X      PrintFPU();
  564. X      printf("\n");
  565. X      return;
  566. X   }
  567. X
  568. X   /* The 32 bit system might have ROMs and things... */
  569. X
  570. X   if (cpu == 68040L) {
  571. X      dmask = CACR_DATA40;
  572. X      shft = CACR_ENABLE40;
  573. X      printf("68040 ");
  574. X      if (tags[CK68040]) quitcode = 0;
  575. X   } else if (cpu == 68030L) {
  576. X      printf("68030 ");
  577. X      if (tags[CK68030]) quitcode = 0;
  578. X   } else {
  579. X      printf("68020 ");
  580. X      if (tags[CK68020]) quitcode = 0;
  581. X   }
  582. X
  583. X   PrintFPU();
  584. X
  585. X   if (mmu == 68851L) {
  586. X      printf("68851 ");
  587. X      if (tags[CK68851]) quitcode = 0;
  588. X   }
  589. X   if (mmu && mmu != BOGUSMMU && mmu != 68040) {
  590. X      mmuon = (GetTC() & TC_ENB);
  591. X      if (tags[CKMMU]) quitcode = 0;
  592. X      if (tags[CKMMUON] && mmuon) quitcode = 0;
  593. X      if (tag = GetSysTag()) {
  594. X         if (tags[CKMMUROM]) quitcode = 0;
  595. X         switch (tag->romtype) {
  596. X            case ROM_FAST:
  597. X               printf("FASTROM "); break;
  598. X            case ROM_KICK:
  599. X               printf("SLOWKICK "); break;
  600. X            case ROM_FKICK:
  601. X               printf("FASTKICK "); break;
  602. X            default:
  603. X               printf("NEWKICK? "); break;
  604. X         }
  605. X      } else if (mmuon) {
  606. X         if (tags[CKMMUALIEN]) quitcode = 0;
  607. X         printf("ALIENMMU ");
  608. X      }
  609. X   } else if (mmu == BOGUSMMU)
  610. X      printf("(FPU LOGIC ERROR) ");
  611. X
  612. X   /* We always print the results, even if nothing has changed. */
  613. X
  614. X   SetCACR(newCACR | CACR_FIXED);
  615. X   newCACR = GetCACR();
  616. X   printf("(INST: ");
  617. X   if (!(newCACR & (imask << shft))) printf("NO");
  618. X   printf("CACHE");
  619. X
  620. X   if (cpu >= 68030L) {
  621. X      if (cpu == 68030) {
  622. X         printf(" ");
  623. X         if (!(newCACR & (CACR_INST << CACR_BURST))) printf("NO");
  624. X         printf("BURST");
  625. X      }
  626. X      printf(") (DATA: ");
  627. X      if (!(newCACR & (dmask << shft))) printf("NO");
  628. X
  629. X      printf("CACHE");
  630. X      if (cpu == 68030) {
  631. X         printf(" ");
  632. X         if (!(newCACR & (CACR_DATA << CACR_BURST))) printf("NO");
  633. X         printf("BURST");
  634. X      }
  635. X   }
  636. X   printf(")\n");
  637. X
  638. X}
  639. X
  640. X/* ====================================================================== */
  641. X
  642. X/* This function returns TRUE is the tag ROM passed is the same version
  643. X   as the actual ROM in use, FALSE otherwise. */
  644. X   
  645. XBOOL CheckVersion(tag)
  646. Xstruct systag *tag;
  647. X{
  648. X   UWORD *tagver,*kickver = (UWORD *)(0x100000C - (*(ULONG *)0xFFFFEC));
  649. X   ULONG *rom = (ULONG *)((ULONG)tag->romhi);
  650. X   
  651. X   tagver = (UWORD *)(((ULONG)rom + SMALLROMSIZE + 0x0C) - rom[0xfffb]);
  652. X   return (BOOL) (kickver[0] == tagver[0] && kickver[1] == tagver[1]);
  653. X}
  654. X
  655. X/* This function deals with the FASTROM/KICKROM patches and the like. */
  656. X
  657. Xvoid DoROMStuff(tag)
  658. Xstruct systag *tag;
  659. X{
  660. X   struct systag *newtag;
  661. X
  662. X   switch (fastrom) {
  663. X      case FR_MKFAST:
  664. X         if (tag) switch (tag->romtype) {
  665. X            case ROM_FAST:
  666. X               DeleteFastROM(tag);
  667. X               if (romfile) {
  668. X                  if (!(newtag = AllocDISKImage(ROM_FAST,romfile))) 
  669. X                     if (LoadErr) quit(LoadErr); else quit(14);
  670. X                  if (!CheckVersion(newtag)) {
  671. X                     DeleteFastROM(newtag);
  672. X                     quit(21);
  673. X                  }
  674. X               } else
  675. X                  newtag = AllocROMImage(ROM_FAST);
  676. X               if (!CreateFastROM(newtag,wrapbits)) quit(14);
  677. X               break;
  678. X            case ROM_KICK:
  679. X               SetupConfig(tag);
  680. X               if (!CreateFastROM(AllocROMImage(ROM_FKICK),wrapbits)) quit(14);
  681. X               FreeSAFEImage(tag);
  682. X               break;
  683. X            case ROM_FKICK:
  684. X               quit(20);
  685. X         } else {
  686. X            if (cpu == 68040) quit(26);
  687. X            if (aliens) quit(27);
  688. X            if (romfile) {
  689. X               if (!(newtag = AllocDISKImage(ROM_FAST,romfile))) 
  690. X                  if (LoadErr) quit(LoadErr); else quit(14);
  691. X               if (!CheckVersion(newtag)) {
  692. X                  DeleteFastROM(newtag);
  693. X                  quit(21);
  694. X               }
  695. X            } else
  696. X               newtag = AllocROMImage(ROM_FAST);
  697. X            if (!CreateFastROM(newtag,wrapbits)) quit(14);
  698. X         }
  699. X         break;
  700. X      case FR_MKKICK:
  701. X         if (tag) switch (tag->romtype) {
  702. X            case ROM_FAST:
  703. X               DeleteFastROM(tag);
  704. X            case ROM_FKICK:
  705. X               if (!CreateKickROM(AllocDISKImage(ROM_KICK,romfile),wrapbits)) 
  706. X                  if (LoadErr) quit(LoadErr); else quit(18);
  707. X            case ROM_KICK:
  708. X               SetupConfig(tag);
  709. X               if (!CreateFastROM(AllocROMImage(ROM_FKICK),wrapbits)) quit(14);
  710. X               FreeSAFEImage(tag);
  711. X               break;
  712. X         } else {
  713. X            if (cpu == 68040) quit(26);
  714. X            if (!CreateKickROM(AllocDISKImage(ROM_KICK,romfile),wrapbits)) 
  715. X               if (LoadErr) quit(LoadErr); else quit(18);
  716. X         }
  717. X         break;
  718. X      case FR_DELETE:
  719. X         if (fastrom == FR_DELETE && tag) {
  720. X            if (tag->romtype != ROM_FAST) quit(13);
  721. X            DeleteFastROM(tag);
  722. X         }
  723. X         break;
  724. X      case FR_NO_ACTION:
  725. X         if (configset && tag) SetupConfig(tag);
  726. X         break;
  727. X   }
  728. X}
  729. X
  730. X/* ====================================================================== */
  731. X
  732. X/* This be the main program. */
  733. X
  734. Xint main(argc,argv)
  735. Xint argc;
  736. Xchar *argv[];
  737. X{
  738. X   struct systag *tag;
  739. X   USHORT i,err;
  740. X
  741. X  /* First we parse the command line.  The default cache operation acts 
  742. X     on both data and instruction caches.  The way all the cache control
  743. X     functions are defined, they're just NOPs on machines without the
  744. X     appropriate caches. */
  745. X
  746. X   if ((cpu = GetCPUType()) >= 68020L) {
  747. X      newCACR = oldCACR = GetCACR();
  748. X      SetCACR(CACR_FIXED|(CACR_INST<<CACR_CLEAR)|(CACR_DATA<<CACR_CLEAR));
  749. X   }
  750. X   for (i = 0; i < CHECKS; ++i) tags[i] = FALSE;
  751. X
  752. X   if (argc > 1 && (err = ParseCommandLine(argc,argv))) quit(err);
  753. X
  754. X   /* If they're just asking for help */
  755. X
  756. X   if (verbose || helpmode)
  757. X      printf("\23333mSetCPU V%1.2f by Dave Haynie\2330m\n",
  758. X             ((float)PROGRAM_VERSION)/100.0);
  759. X
  760. X   if (helpmode) quit(1);
  761. X
  762. X  /* The FastROM routine uses the expansion library.  It's possible to have
  763. X     an old version of the OS without this, so I'll be careful to avoid
  764. X     using any ExpansionBase function without checking for the base being
  765. X     valid. */
  766. X
  767. X   if (ExpansionBase = (struct ExpansionBase *)OpenLibrary("expansion.library",0L))
  768. X      SnoopDevs();
  769. X   
  770. X  /* Let's find out what we have, and perform the ROM translation, if it's
  771. X     requested and hasn't been done already. */
  772. X
  773. X   fpu = GetFPUType();
  774. X   if ((mmu = GetMMUType()) && mmu != BOGUSMMU) {
  775. X      tag = GetSysTag();
  776. X      aliens = (GetTC() & TC_ENB) && !tag;
  777. X   }
  778. X
  779. X   if (mmu && mmu != BOGUSMMU) DoROMStuff(tag);
  780. X   PrintSystem();
  781. X   if (verbose && cpu >= 68020 && (GetTC() & TC_ENB)) PrintFastROM();
  782. X   quit(quitcode);
  783. X}
  784. X
  785. END_OF_FILE
  786. if test 23981 -ne `wc -c <'SetCPU.c'`; then
  787.     echo shar: \"'SetCPU.c'\" unpacked with wrong size!
  788. fi
  789. # end of 'SetCPU.c'
  790. fi
  791. if test -f 'SetCPU.txt' -a "${1}" != "-c" ; then 
  792.   echo shar: Will not clobber existing file \"'SetCPU.txt'\"
  793. else
  794. echo shar: Extracting \"'SetCPU.txt'\" \(20967 characters\)
  795. sed "s/^X//" >'SetCPU.txt' <<'END_OF_FILE'
  796. X
  797. X             SetCPU V1.60
  798. X            by Dave Haynie
  799. X            June 15, 1990
  800. X
  801. X    SetCPU V1.60 is a program designed for identification and
  802. Xmodification of system parameters roughly related to different versions 
  803. Xof the Motorola 68000 family processors.  The program will identify the 
  804. Xvarious types of processors and coprocessors in any 680x0 system.  It also
  805. Xmakes an attempt to correctly identify an incorrectly designed but still
  806. Xpossibly functional 68020 system, several of which are known to exist as
  807. XAmiga coprocessor boards.  It contains MMU code to locate kernel ROM in
  808. Xwrite protected 32 bit ROM.
  809. X
  810. X    In any case, the syntax of the program is given as follows:
  811. X
  812. X    SetCPU [INST|DATA] [[NO]CACHE|[NO]BURST] [CONFIG n]  [BITS n] [TRAP n]
  813. X           [KICKROM path|dfN: [DELAY n] [KEEPEXEC]] [CARDROM path] [VERBOSE]
  814. X           [[NO]FASTROM [path] [KEYPATCH n] [HEAD] [NOSTACK]] [ROMBOOT]
  815. X           [CHECK 680x0|68851|6888x|MMU|FPU|MMUON|MMUROM|MMUALIEN]
  816. X
  817. Xwhere "[]" indicates an optional parameter, "|" indicates a choice of
  818. Xparameters.  Typing "SetCPU ?" will retrieve this same syntax diagram.
  819. XTyping SetCPU alone will result in the SYSTEM configuration being 
  820. Xsend to the console, my current system returns this:
  821. X    SYSTEM: 68030 68882 FASTROM (INST: CACHE NOBURST) (DATA: CACHE NOBURST)
  822. X
  823. XThis indicates I have a 68030/68882 system, I've previously installed the 
  824. XFASTROM translation, and both caches are turned on.  Issuing the command
  825. X"SetCPU FASTOM CACHE" would recreate such a setup.  Note that any parameters
  826. Xthat don't make sense to the real system configuration, such as asking to
  827. Xmodify the data cache on a 68020 system or install the FASTROM translation 
  828. Xon a 68000 system are just ignored.
  829. X
  830. X[0] CHANGES
  831. X
  832. X    Since the V1.50 release of SetCPU, the following changes have been
  833. Xmade to the SetCPU program:
  834. X
  835. X    - FASTROM now supports loading of a ROM image file.
  836. X
  837. X    - The patch manager has been removed, except for the KEYPATCH
  838. X      option.
  839. X
  840. X    - ROMs beyond 256K are now supported, from both file and special
  841. X      KickStart disk.
  842. X
  843. X    - ROM images are supported assembled for various memory locations,
  844. X      so that Commodore's developer files assembled at $00F00000, for
  845. X      example, will work.  SetCPU determines the size, base, and
  846. X      jump address of a ROM independently.
  847. X
  848. X    - ExecBase can be erased on KICKROM resets to prevent Chip RAM
  849. X      sizing problems and other OS switching errors.
  850. X
  851. X    - A programmable KICKROM DELAY option allows KICKROM to work on
  852. X      better on some machines with extremely slow 8520 startup times.
  853. X
  854. X    - Caching for any Bridge Card memory will always be disabled.
  855. X
  856. X    - The system stack, if found in Chip memory, is relocated to Fast
  857. X      memory for FASTROM translations.
  858. X
  859. X    - Some 2.0 functions are activated when run under the 2.0 OS, so
  860. X      that most if not all of the basic SetCPU functions operate 
  861. X      properly.
  862. X
  863. X    - The MMU code is intelligent enough to avoid trashing an MMU setup
  864. X      not generated by SetCPU.
  865. X
  866. X[1] DISTRIBUTION
  867. X
  868. X    This program is placed in the public domain, and may be used or
  869. Xdistributed as you like.
  870. X
  871. X
  872. X[2] CPU IDENTIFICATION
  873. X
  874. X    There are two basic types of functions performed by SetCPU.  The 
  875. Xfirst of these is CPU system identification and cache control.  SetCPU will 
  876. Xtell about the type of CPU setup in your machine, which consists of the CPU
  877. Xitself and sometimes FPU or MMU coprocessors.  If the CPU supports caches,
  878. XSetCPU will let you switch these caches, and associated cache line burst mode,
  879. Xon and off.  Finally, SetCPU can be used in a Startup-Sequence or other script
  880. Xto make decisions based on the system that's running.  This is quite useful 
  881. Xwith accelerator cards like the Commodore A2620 that let you boot the machine
  882. Xwith either 68020 or 68000 in charge.  The individual CPU group commands are 
  883. Xgiven below in detail:
  884. X
  885. X[NO]CACHE
  886. X    This command will switch on or off 68020 and 68030 caches.  If not 
  887. X    qualified, it'll act on both instruction and data caches of the 68030.
  888. X
  889. X[NO]BURST
  890. X    This command will switch on or off the burst cache line fill request 
  891. X    of the 68030.  If not qualified, it'll act on both instruction and 
  892. X    data caches.
  893. X
  894. XINST
  895. X    This qualifies a CACHE or BURST operation to restrict its application
  896. X    to the instruction cache only.
  897. X
  898. XDATA
  899. X    This qualifies a CACHE or BURST operation to restrict its application
  900. X    to the data cache only.
  901. X
  902. XCHECK 
  903. X    This option lets you check for the existence of a particular CPU 
  904. X    system component in a script.  It works like this:
  905. X
  906. X        SetCPU CHECK 68020
  907. X        If WARN
  908. X            echo "No 68020 here!"
  909. X        Else
  910. X            echo "Sho nuff got a 68020 here!"
  911. X        Endif
  912. X
  913. X    The arguments to CHECK can be any of:
  914. X
  915. X        68000        Matches the obvious
  916. X        68010        "
  917. X        68020        "
  918. X        68030        "
  919. X        68040        "
  920. X        68851        "
  921. X        68881        "
  922. X        68882        "
  923. X        FPU        Matches 68881, 68882, or 68040
  924. X        MMU        Matches 68851, 68030, or 68040
  925. X            MMUON        Matches any case in which the MMU is enabled
  926. X        MMUROM        Matches an active SetCPU ROM translation
  927. X        MMUALIEN    Matches any MMU setup no created by SetCPU
  928. X
  929. XIf any cache parameter doesn't apply to the system in use, it'll just be
  930. Xignored.  Use the data cache and all burst modes with caution.  Some 
  931. X68030 systems aren't designed to correctly support the data cache, so
  932. Xswitching it on may cause an instant system crash.  Even on systems that
  933. Xcorrectly support the 68030 data cache, some device drivers, especially
  934. Xthose for DMA devices, may not work properly with the data cache enabled.
  935. XYou may wish to check with your system vendors to make sure before using
  936. Xthe data cache in your standard system setup.  The Commodore A2091's device
  937. Xdriver does correctly support data caching.  However, the use of the data
  938. Xcache is not recommended without an MMU setup, such as FASTROM or one of
  939. Xthe KICK setups, invoked.  The Amiga OS uses memory that's the same in
  940. Xboth Supervisor and User modes of the 680x0.  This requires the setting
  941. Xof the 68030's Write Allocate bit for safe operation, and SetCPU will
  942. Xalways insure that Write Allocate is set.  However, this mode causes the
  943. Xdata cache to be updated on longword writes even for locations that are
  944. Xdriven noncacheable in hardware.  So data caching without a proper MMU
  945. Xsetup can cause problems with some I/O devices.  With the MMU setup, 
  946. XSetCPU will map the standard Amiga I/O regions as noncachable.
  947. X
  948. X    SetCPU may report a "FPU Logic Error" on certain 68020 systems.  
  949. XThis is indicating a hardware problem with that board's floating point 
  950. Xcoprocessor decoding, which results in the FPU responding to the MMU 
  951. Xaddresses as well as its own.  SetCPU knows how to handle such a board,
  952. Xbut future software using the MMU may not, so it's a good idea to report
  953. Xthis problem to the board vendor for repair.
  954. X
  955. X
  956. X[3] ROM TRANSLATIONS
  957. X
  958. X    The second thing that SetCPU V1.60 manages are ROM translations.  
  959. XUsing the MMU on systems so equipped, it can locate the Kernel ROM in the
  960. Xmuch faster 32 bit wide memory provided on many 32 bit systems.  It can
  961. Xalso boot a ROM based system with an alternate version of KickStart.
  962. XMost of the options here relate to MMU translation setup and various 
  963. Xmodifications of the basic translation premise.
  964. X
  965. X    As of this release, SetCPU's MMU configurations will support
  966. Xmemory outside of the 68000's 24 bit address space, when it is present.
  967. XSuch memory will be automatically recognized and supported by SetCPU if
  968. Xit is linked into the free memory lists when SetCPU builds its FASTROM
  969. Xor KICKROM.  Alternatively, the number of significant bits of address
  970. Xin the system can be specified by the BITS command, and SetCPU will
  971. Xbuild the appropriate MMU table for such a system.
  972. X
  973. X    Another feature of this release is support for ROM images of either 
  974. X256K or 512K in size.  KickROMs may be assembled for locations other than the
  975. X$00FC0000 or $00F80000 base used by physical systems.  SetCPU will compute
  976. Xthe size, base address, and start address for any KickROM image.  ROM
  977. Ximages can now be loaded from disk for FASTROM translations as well as
  978. XKICKROM translations, though a FASTROM image must be the same KickStart
  979. Xrelease as the current ROM in the system.  This facility's main purpose is
  980. Xto support loading of patched ROMs with the necessity of rebooting via
  981. XKICKROM.  As a result of this, the only patch now done by SetCPU itself is
  982. Xthe optional KEYPATCH, which may be required for proper operation of the
  983. Xaccelerated ROM code on some systems. 
  984. X
  985. X
  986. X[NO]FASTROM
  987. X    This activates the FASTROM translation on or off an MMU equipped 
  988. X    system.  When switching on, it first allocates at least 256K of 
  989. X    memory for the ROM image, then at least 512 bytes of memory for the
  990. X    MMU table.  It copies the ROM into the image area, then applies the 
  991. X    translation by pointing the MMU at the table and activating it.  The 
  992. X    NOFASTROM option will switch off the MMU and reclaim the memory used 
  993. X    for the ROM image and MMU table.  If any other program set up the MMU
  994. X    for something, invoking this option could be a very bad thing to do.
  995. X    In general, until there's some level of OS support for the MMU in 
  996. X    Amiga systems, you're really safe using only one MMU tool at a time.
  997. X    If you have an A2620 or A2630 system, this option will always get 32
  998. X    bit memory for you; if not, you'll have to make sure that your 32 bit
  999. X    memory is the first MEMF_FAST memory in the memory list for it to be 
  1000. X    used for the ROM image.  Also, that ROM image will be allocated as far
  1001. X    back on that memory list as possible unless the "HEAD" option is 
  1002. X    specified.  The SetCPU "SYSTEM" line will report this setup as a
  1003. X    "FASTROM" setup.
  1004. X
  1005. XSuboptions are:
  1006. X
  1007. X    file
  1008. X        Specifying a file with a valid ROM image will load that ROM
  1009. X        image instead of the system's physical ROM image.  The one
  1010. X        restriction is that the disk-loaded ROM image must be the
  1011. X        same ROM revision as the current system ROM.  If they aren't
  1012. X        the same revision, the KICKROM option can be used instead,
  1013. X        but that'll require a reboot.  This option can be used to
  1014. X        load a patched version of the current ROM without reboot in
  1015. X        most cases. 
  1016. X
  1017. X    KEYPATCH n
  1018. X        This will patch the keyboard scanning routine for machines 
  1019. X        that have Cherry keyboards (small function keys).  The "n"
  1020. X        parameter allows a variable delay between 1 and 100 to be
  1021. X        specified; the delay depends on the keyboard, but should
  1022. X        be pretty independent of CPU speed.
  1023. X
  1024. X    NOSTACK
  1025. X        This will prevent the attempted translation of supervisor
  1026. X        stack into 32 bit memory.  By default, such translation will
  1027. X        be done if the supervisor stack is found in Chip memory.
  1028. X    
  1029. X
  1030. XCARDROM path
  1031. X
  1032. X    When used in conjunction with the FASTROM option, this allows ROMs
  1033. X    from expansion cards to be located in fast memory as well.  The
  1034. X    path should reference a file containing lists of expansion cards
  1035. X    that should be translated if found.  It's necessary to read this
  1036. X    from a user-defined file, rather than from the expansion environment
  1037. X    itself, since an expansion device's ROM could be located close to
  1038. X    that device's registers; there's no way for SetCPU to know it's
  1039. X    safe to translate a card ROM image unless you tell it.  On my system
  1040. X    I read a file called CardROMList, which currently contains the single
  1041. X    line:
  1042. X
  1043. X        0x202 0x01 0x10000 0x8000 0x4000 CBM_2090A_Disk_Controller
  1044. X
  1045. X    All the numbers given are in C language hex format.  The parameters
  1046. X    are, in order, the device's manufacturer code, product code, the
  1047. X    device's size (in bytes), the ROM's offset from the configured board's
  1048. X    base address (in bytes), and the size of the ROM area to be
  1049. X    translated (in bytes).  The final item is text string to identify
  1050. X    the device; this'll be displayed by the VERBOSE option if the ROM
  1051. X    translation does in fact take place.  The "_" characters in the
  1052. X    name will be translated to " " characters.  Note that the CardROM
  1053. X    translations are currently based on 16K chunks, and SetCPU will
  1054. X    ignore requests for translations of less than 16K, and round down to
  1055. X    16K boundaries for larger translation requests.  
  1056. X
  1057. XHEAD
  1058. X    This option causes the SetCPU memory allocator to attempt memory
  1059. X    allocation for its translated objects from the start of 32 bit
  1060. X    memory instead from the end, as it usually does.  Allocation from 
  1061. X    the end usually results in less fragmentation than from the start
  1062. X    (due to the alignment restrictions of MMU objects), though this
  1063. X    option is useful when dealing with merged memory lists.  It is
  1064. X    ignored when the ROM image and tables are in chip/$00C00000 memory.
  1065. X
  1066. XKICKROM path|dfN:
  1067. X
  1068. X    The KickROM option allows the system to be restarted with an
  1069. X    alternate ROM image.  This can be from a KickStart disk in a
  1070. X    specified floppy drive, or from a given file name.  If the
  1071. X    ROM image is accessible, this command will cause the system to
  1072. X    be immediately rebooted into the new OS.  Note that pre-1.3
  1073. X    versions of the Amiga operating system will probably have some
  1074. X    trouble with expansion cards, especially autoboot cards.  For
  1075. X    that reason there's the CONFIG 0 option, which is explained
  1076. X    later.
  1077. X
  1078. X    The KICKROM command will reboot the machine with the new OS, but
  1079. X    that ROM image will be physically located in either memory at
  1080. X    $00C00000, if it's available, otherwise it'll use Chip memory.  Once 
  1081. X    the new OS has started up, issuing either "SetCPU FASTROM ..." or
  1082. X    "SetCPU KICKROM..." will cause that image to be moved into fast
  1083. X    memory, and the slow memory will be given back to the system.  The
  1084. X    SetCPU "SYSTEM" line will report a 16 bit KICKROM image as a
  1085. X    "SLOWKICK", and a 32 bit KICKROM image as a "FASTKICK".  A machine
  1086. X    running from a SLOWKICK kernel can't be re-KICKROMed, but can be
  1087. X    from a FASTKICK kernel.
  1088. X
  1089. XSuboptions are:
  1090. X
  1091. X    DELAY n
  1092. X        This option sets the delay after reset before any code is
  1093. X        run.  The parameter may be set from 0 to 100, where 0 sets
  1094. X        no delay.  The default value is 10, which sets the delay
  1095. X        value used in SetCPU V1.50.  The need for a delay depends
  1096. X        on the machine you're on.  If your machine hangs after
  1097. X        SetCPU loads KickStart, there's a real good chance that
  1098. X        you need a longer delay.
  1099. X
  1100. X    KEEPEXEC
  1101. X        Normally, KICKROM will clear the ExecBase pointer, to cause a
  1102. X        the new version of the ROM to be rebuild from a cold boot
  1103. X        condition.  This option prevents that clearing action.
  1104. X        
  1105. XCONFIG n
  1106. X    This option controls if and how expansion devices are recognized on 
  1107. X    a KICKROM boot.  At the default configuration level, level 2, the
  1108. X    expansion cards are left alone, allowing the new Kernel to try and
  1109. X    configure them.  Since some older operating system will choke on 
  1110. X    autoboot devices, this option will allow suppression of them for the
  1111. X    rebooting process.  When requesting a KICKROM boot, a CONFIG level
  1112. X    of 0 or 1 will prevent the devices from being recoginzed.
  1113. X
  1114. X    Once rebooted in the new OS, moving from a SLOW    to a FAST Kick image,
  1115. X    as described above, the CONFIG status will be honored.  If the
  1116. X    devices weren't suppressed, nothing special happens.  If they were,
  1117. X    they'll stay suppressed, and you very likely won't have the memory
  1118. X    to support a FAST Kick image.  Specifying a CONFIG level of 2 at
  1119. X    this point will attempt to configure the devices without autobooting.
  1120. X    At level 1, the devices will be made visable to the system again,
  1121. X    but nothing will be done with them.
  1122. X
  1123. X    As of the latest release, CONFIG 0 appears to be required with the 
  1124. X    1.2 operating system, at least if there's any autoboot device, even if
  1125. X    you're attempting to move from a slow to fast kick image.  The next 
  1126. X    release will attempt to allow 1.2 to configure non-autobooting devices
  1127. X    at this point.
  1128. X
  1129. XTRAP n
  1130. X    This option controls the level of error trapping handled for 
  1131. X    you by the SetCPU system.  The numeric parameter is actually 
  1132. X    optional for compatibility with SetCPU V1.4.  If no TRAP is 
  1133. X    specified, the default level 2 is enacted.  If the TRAP command is 
  1134. X    given without a parameter, trap level 0 will be setup.  
  1135. X
  1136. X    Trap level 0 causes the MMU to look at all 32 bits of address;
  1137. X    access to any memory outside of the 24 bit space will result
  1138. X    in an exception, which if unhandled, results in a GURU 2.  Trap
  1139. X    level 1 will set up the MMU to only look at 24 bits of address space. 
  1140. X    Trap level 2 works like level 1, but additionally sets up a trap
  1141. X    handler for the Bus Error exception (which usually surfaces as a
  1142. X    GURU #2).  For normal operation (eg, running other people's code),
  1143. X    Trap level 2 is probably what you want.  For final testing of your
  1144. X    own code, levels 0 or 1 can catch things which would go unnoticed
  1145. X    on a 68000 machine, such as writing to ROM space or out of the 24
  1146. X    bit address space.
  1147. X
  1148. X    The exception handler used for level 2 trapping catches things like
  1149. X    writes to protected areas of memory.  It just tells the bus machine
  1150. X    not to complete the write, and signals no error.  There's a slight
  1151. X    chance that this won't be enough repair for a program doing something
  1152. X    really outlandish -- at that point, running at level 1 will let the
  1153. X    GURU happen, which might help if you're debugging your own code.  
  1154. X    Other that that, there's probably nothing you can do to get such a
  1155. X    program working with the MMU turned on, other than having it fixed.
  1156. X    The other thing to consider is that this exception handler could
  1157. X    conflict with another system-level handler installed by a GOMF-like
  1158. X    program.  That shouldn't cause a big problem, since you'll the one
  1159. X    that was installed later, both of which presumably trap the error,
  1160. X    but it's something to be aware of.
  1161. X
  1162. X    Under V1.3 and earlier releases, a DOS bug can cause invalid accesses,
  1163. X    which cause the exception, when running the EndCLI or NewCLI/NewShell 
  1164. X    programs; running at level 1 or 2 will avoid gurus with these commands.
  1165. X
  1166. X
  1167. XBITS    n
  1168. X    This option forces the MMU table for KICKROM or FASTROM to be built
  1169. X    to support a specific number of bits, regardless of the actual bits
  1170. X    apparently used by the system.  Valid significant bits range from 24
  1171. X    through 32.
  1172. X
  1173. XROMBOOT
  1174. X    This option forces a reset to physical ROM without hanging the system,
  1175. X    even when the MMU is active.
  1176. X
  1177. XVERBOSE    
  1178. X    This option more fully describes the system translations. 
  1179. X
  1180. X
  1181. X[4] ROM FILE FORMATS
  1182. X
  1183. X    The 256K KickStart disk the KICKROM option will look for is the
  1184. Xstandard Commodore KickStart format, which is a standard format floppy
  1185. Xwith the work "KICK" at the start of the disk, followed by 512 blocks of
  1186. X512 bytes each, a plain dump of the ROM image.  512K KickStart disks 
  1187. Xlook just the same, only, of course, with 512K of ROM.  The KickStart
  1188. Xloader will actually check the first 32 blocks of disk for the start of
  1189. XROM.
  1190. X
  1191. X    The size of the KickStart image is determined by the first longword
  1192. Xof the file.  Optionally, disk files can contain two extra longwords at the
  1193. Xbeginning of the file, the first being a $00000000, second the expected 
  1194. Xsize of the ROM image.  That expected size will be compared with the expected
  1195. Xbased on the first longword in the ROM image and the actual length of the
  1196. Xloaded file, in the case of a disk file rather than a KickStart. The base
  1197. Xaddress and starting address are determined from the ROM image, and SetCPU
  1198. Xwill attempt to use them.  Some ROM images can cause a conflict with other
  1199. Xsystem resources.
  1200. X
  1201. X[5] CREDITS
  1202. X
  1203. X    While this program is an entirely original work, nothing happens in
  1204. Xvaccuum, this one included.  I'd like to mention folks who, directly or
  1205. Xindirectly, helped make this thing happen, by providing example MMU code,
  1206. Xsuggestions, and incentives.  These folks include Neil Katin, Jez San,
  1207. XGVP Inc., Dale Luck, Bryce Nesbitt, Andy Finkel, and the other Commodore-Amiga 
  1208. Xsoftware people, and the Commodore-Amiga Technical Support folks.
  1209. X
  1210. X[6] POTENTIAL BUGS AND OTHER NOTES
  1211. X
  1212. X    I should point out here that much of what SetCPU does is of a rather
  1213. Xdubious nature.  Everything that's possible to do correctly under the 2.0 
  1214. Xrelease of the OS, including CPU/FPU identifications and cache control, is
  1215. Xdone via the approved 2.0 methods when running in 2.0, and via my own tricks
  1216. Xwhen run under 1.3 or earlier releases.  
  1217. X
  1218. X    While it's impossible for an application to correctly use the MMU under
  1219. X1.3 or 2.0, SetCPU attempts to be intelligent about its use of the MMU.  It 
  1220. Xwill check for the use of the MMU by an agent other than SetCPU, and refuse to
  1221. Xmodify the current MMU setup if such an alien MMU setup is found.  For systems
  1222. Xwith an unused MMU, SetCPU will do it's best to be safe about the modifications
  1223. Xit makes to the memory map.  There may be problems with this program's MMU
  1224. Xcode on the Amiga 3000, but based on the SuperKickStart and CPU programs that
  1225. Xare shipped with the first A3000s, this should not be of immediate concern,
  1226. Xsince the A3000 comes with equivalent functionality.  Should an A3000-safe 
  1227. Xversion of SetCPU eventually become needed, I'll make the attempt to track
  1228. Xdown any A3000 bugs I can find.  Just because you help design a machine doesn't
  1229. Xnecessarily mean you have one to code and test on at home.
  1230. X
  1231. X    Finally, if you wish to contact me regarding bug reports, new
  1232. Xreleases, contributions of cash or macadamia nuts, or pretty much anything
  1233. Xelse, I can be reached at the below addresses.  
  1234. X
  1235. X
  1236. X            -Dave Haynie
  1237. X
  1238. X        Logical Address:
  1239. X             PLINK:        hazy
  1240. X             bix:        hazy
  1241. X             usenet:    {uunet,rutgers}!cbmvax!daveh
  1242. X
  1243. X        Physical Address:
  1244. X
  1245. X             284 Memorial Drive
  1246. X             Gibbstown, NJ
  1247. X             08027
  1248. END_OF_FILE
  1249. if test 20967 -ne `wc -c <'SetCPU.txt'`; then
  1250.     echo shar: \"'SetCPU.txt'\" unpacked with wrong size!
  1251. fi
  1252. # end of 'SetCPU.txt'
  1253. fi
  1254. echo shar: End of archive 3 \(of 4\).
  1255. cp /dev/null ark3isdone
  1256. MISSING=""
  1257. for I in 1 2 3 4 ; do
  1258.     if test ! -f ark${I}isdone ; then
  1259.     MISSING="${MISSING} ${I}"
  1260.     fi
  1261. done
  1262. if test "${MISSING}" = "" ; then
  1263.     echo You have unpacked all 4 archives.
  1264.     rm -f ark[1-9]isdone
  1265. else
  1266.     echo You still need to unpack the following archives:
  1267.     echo "        " ${MISSING}
  1268. fi
  1269. ##  End of shell archive.
  1270. exit 0
  1271. -- 
  1272. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  1273. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  1274. Post requests for sources, and general discussion to comp.sys.amiga.
  1275.